package vistas.clientes;
import java.util.Iterator;
import java.util.List;

import javax.swing.JTable;

import javax.swing.WindowConstants;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.SwingUtilities;

import dominio.Cliente;

import app.Odv;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class ListaDeClientes extends javax.swing.JFrame {
	private DefaultTableModel tableModel;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				ListaDeClientes inst = new ListaDeClientes();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public ListaDeClientes() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			{
				
				
				Odv s= Odv.getinstancia();
				List<Cliente>lista = s.listaDeCliente();
				
				Object[][] data = new Object[][] { };
				this.tableModel = new DefaultTableModel(data, new String[] { 
				                "Razon Social", "Domicilio", "Telefono", "CUIL" });
				JTable table = new JTable(this.tableModel);
				Iterator<Cliente> it = lista.listIterator();
				while(it.hasNext()){
					Cliente c = (Cliente) it.next();
					this.tableModel.addRow(c.parseClienteToStringRow());
				}
				
				getContentPane().add(table);
				
				table.setBounds(110, 39, 107, 211);
			}
			pack();
			setSize(400, 300);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

}
